{extend name="base/index"/}

{block name="page_location"}
{/block}

{block name="body"}
<div class="row">
	<div class="col-12">
		<div class="page-title-box">
			<div class="page-title-right">
				<ol class="breadcrumb m-0">
					<li class="breadcrumb-item">
						<a href="{:url('index/index')}">管理中心</a>
					</li>
					<li class="breadcrumb-item active"><i class="iconfont icon-angle-right"></i>【{$model_name}】字段管理</li>
				</ol>
			</div>
			<h4 class="page-title">
				【{$model_name}】模型字段列表
				<a href="javascript:;" class="btn btn-success btn-sm ml-3" data-toggle="modal" data-target="#edit_box" id="add_mobelfield_btn">创建新的模型字段</a>
				<a href="javascript:;" class="btn btn-success btn-sm ml-3" data-toggle="modal" data-target="#select_model_box">选择模型</a>
				<a href="javascript:;" class="btn btn-success btn-sm ml-3" id="Fast_Sort" attr-model="modelfield" attr-frm="modelfield_list_frm">更新排序</a>
			</h4>
		</div>
	</div>
</div>
<div class="row" id="model_field_page">
	<div class="col-12">
		<div class="card">
			<div class="card-body">
				<div class="table-responsive-lg">
					<form action="" method="post" id="modelfield_list_frm">
						<table class="table table-hover">
							<thead>
								<tr>
									<th>ID</th>
									<th>所属模型</th>
									<th>字段标题</th>
									<th>字段名称</th>
									<th>字段类型</th>
									<th>数据类型</th>
									<th>数据长度</th>
									<th>列表显示</th>
									<th>搜索类型</th>
									<th>更新时间</th>
									<th>状态</th>
									<th>排序</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								{volist name="list" id="data"}
								<tr>
									<td>{$data.id}</td>
									<td>{$data.model_name}</td>
									<td>{$data.field_title}</td>
									<td>{$data.field_name}</td>
									<td>{$data.field_type}</td>
									<td>{$data.data_type}</td>
									<td>{$data.data_length}</td>
									<td>
										{eq name="data.list_show" value="0"}
										<a href="javascript:;" attr-model="modelfield" attr-id="{$data.id}" attr-field="list_show" attr-val="1"
										 class="badge badge-primary Fast_Action">显示</a>
										{else /}
										<a href="javascript:;" attr-model="modelfield" attr-id="{$data.id}" attr-field="list_show" attr-val="0"
										 class="badge badge-secondary Fast_Action">不显示</a>
										{/eq}
									</td>
									<td>
										{switch name="data.search_type"}
											{case value="0"} <span class="badge badge-secondary">无搜索</span> {/case}
											{case value="1"} <span class="badge badge-primary">模糊匹配搜索</span>{/case}
										{/switch}
									</td>
									<td>{$data.posttime|date="y-m-d H:i",###}</td>
									<td>
										{eq name="data.status" value="0"}
										<a href="javascript:;" attr-model="model_field" attr-id="{$data.id}" class="badge badge-primary  hidden_btn">启用</a>
										{else /}
										<a href="javascript:;" attr-model="model_field" attr-id="{$data.id}" class="badge badge-secondary  show_btn">禁用</a>
										{/eq}
									</td>
									<td>
										<input type="hidden" name="field_ids[]" value="{$data.id}" />
										<input type="number" class="form-control orderid_ipt" name="orderid_ipt[]" value="{$data.orderid}">
									</td>
									<td>
										<a href="javascript:;" class="btn btn-primary btn-sm edit_btn" attr-id="{$data.id}" data-toggle="modal" data-target="#edit_box"><i class="iconfont icon-icon_compile"></i>修改</a>
										<a href="javascript:;" class="btn btn-danger btn-sm Fast_Del" attr-id="{$data.id}" attr-model="modelfield"><i class="iconfont icon-icon_delete_fill"></i>删除</a>
									</td>
								</tr>
								{/volist}
							</tbody>
						</table>
					</form>
					<div class="row">
						<div class="col-12" style="text-align: center;">
							{$pagelist}
						</div>
					</div>
				</div>
				<!-- end table-responsive-->
			</div>
			<!-- end card body-->
		</div>
		<!-- end card -->
	</div>
	<!-- end col-->
</div>
<!-- END PAGE CONTENT-->
{/block}
{block name="modal_dig"}
<!-- Modal -->
<div class="modal fade" id="edit_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog modal-full-70">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title dig_title" id="myModalLabel">修改模型字段信息</h4>
				<button type="button" class="close" data-dismiss="modal">x</button>
			</div>
			<div class="modal-body">
				<form action="#" class="form-horizontal" id="edit_model_field_frm">
					<input type="hidden" name="id" value="" />
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">选择所属模型：</label>
						<div class="col-5">
							<select class="form-control" tabindex="1" name="mid">
								<option value="0" selected="selected">请选择模型</option>
								{volist name="model_list" id="data"}
								<option value="{$data.id}">{$data.model_name}</option>
								{/volist}
							</select>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段类型：</label>
						<div class="col-8">
							<select class="form-control" tabindex="1" name="field_type" style="width:40%;margin-right:10px;float: left;">
								{volist name="types" id="data"}
								<option value="{$data.name}">{$data.title}</option>
								{/volist}
							</select>
							<select class="form-control" tabindex="1" name="data_type" style="width:40%;margin-right:10px;float: left;">
								<optgroup label="数字类型">
									<option value="tinyint">TINYINT(小整数)</option>
									<option value="mediumint">MEDIUMINT(中整数)</option>
									<option value="int">INT(大整数)</option>
									<option value="bigint">BIGINT(超大整数)</option>
									<option value="float">FLOAT(小数,浮点数)</option>
									<option value="decimal">DECIMAL(小数,高精度数)</option>
								</optgroup>
								<optgroup label="字符类型">
									<option value="char">CHAR(短字符)</option>
									<option value="varchar">VARCHAR(字符串)</option>
									<option value="text">TEXT(文本类型)</option>
									<option value="mediumtext">MEDIUMTEXT(大型文本)</option>
									<option value="longtext">LONGTEXT(超大型文本)</option>
								</optgroup>
							</select>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">数据长度：</label>
						<div class="col-5">
							<input type="text" name="data_length" placeholder="请输入字段长度" class="form-control ipt_check" value="100" data-type="float"
							 data-len="2-10" nullmsg="字段长度不能为空" errormsg="字段长度只能由2到10位的数字组成">
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">数据符号(是否有负数)：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="unsigned" id="unsigned3" class="custom-control-input" value="" checked="checked">
								<label class="custom-control-label" for="unsigned3">有符号</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="unsigned" id="unsigned4" class="custom-control-input" value="UNSIGNED">
								<label class="custom-control-label" for="unsigned4">无符号</label>
							</div>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段名称：</label>
						<div class="col-5">
							<input type="text" name="field_name" placeholder="请输入字段名称" class="form-control ipt_check" value="" data-type="enname"
							 data-len="2-20" nullmsg="字段名称不能为空" errormsg="字段名称只能由2到20位的字母、数字组成">
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段标题：</label>
						<div class="col-5">
							<input type="text" name="field_title" placeholder="请输入字段标题" class="form-control ipt_check" value="" data-type="name"
							 data-len="2-12" nullmsg="字段标题不能为空" errormsg="字段标题只能由2到12位的下划线的任何单词字符和数字和中文组成">
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1 not_relation_input_box">
						<label class="col-3 col-form-label">字段数据：</label>
						<div class="col-5">
							<textarea name="field_data" rows="5" class="form-control" placeholder="选项名称:选项值"></textarea>
							<span class="font-13 text-muted">注：用于单选、多选、列表类型，每行一个选项</span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段编辑校验：</label>
						<div class="col-5">
							<div class="relation_list_box">
								<select class="form-control" name="verify_type" id="verify_type" style="width:40%;margin-right:10px;float: left;">
									<option value="">无需校验</option>
									<option value="string">任何字符</option>
									<option value="name">下划线/任何字符/数字/中文</option>
									<option value="zhname">中文文字</option>
									<option value="enname">英文文字</option>
									<option value="integer">整型</option>
									<option value="float">浮点，货币型</option>
									<option value="mobile">手机号码</option>
									<option value="phone">固定电话</option>
									<option value="email">邮箱类型</option>
									<option value="url">网址类型</option>
									<option value="postcode">邮政编码类型</option>
									<option value="ip">IP地址</option>
									<option value="upload">上传文件类型</option>
								</select>
								<input type="text" name="verify_len" placeholder="请输入字段长度" class="form-control" value="5-150" style="width:40%;">
							</div>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段默认值：</label>
						<div class="col-5">
							<input type="text" name="default_value" placeholder="请输入字段标题" class="form-control" value="">
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段备注信息：</label>
						<div class="col-5">
							<input type="text" name="hint" placeholder="请输入字段标题" class="form-control" value="">
							<span class="font-13 text-muted"></span>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">显示在列表：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="list_show" id="list_show3" class="custom-control-input" value="" checked="checked">
								<label class="custom-control-label" for="list_show3">显示</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="list_show" id="list_show4" class="custom-control-input" value="1">
								<label class="custom-control-label" for="list_show4">不显示</label>
							</div>
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">搜索类型：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="search_type" id="search_type4" class="custom-control-input" value="0" checked="checked">
								<label class="custom-control-label" for="search_type4">无搜索</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="search_type" id="search_type5" class="custom-control-input" value="1">
								<label class="custom-control-label" for="search_type5">模糊匹配搜索</label>
							</div>				
						</div>
					</div>						
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段排序：</label>
						<div class="col-5">
							<input type="text" name="orderid" placeholder="请输入字段排序" class="form-control ipt_check" value="" data-type="integer"
							 data-len="1-4" nullmsg="字段排序不能为空" errormsg="字段排序只能由1到4位的数字组成">
						</div>
					</div>
					<div class="form-group row mb-1">
						<label class="col-3 col-form-label">字段状态：</label>
						<div class="col-5">
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status3" class="custom-control-input" value="0" checked="checked">
								<label class="custom-control-label" for="status3">启用</label>
							</div>
							<div class="custom-control custom-radio">
								<input type="radio" name="status" id="status4" class="custom-control-input" value="1">
								<label class="custom-control-label" for="status4">禁用</label>
							</div>
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary Fast_Form_Post" attr-frm="#edit_model_field_frm" attr-model="modelfield"
				 attr-active="save_field" attr-callback="reload">确认修改</button>
			</div>
		</div>
	</div>
</div>

<div class="modal fade" id="select_model_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<h4 class="modal-title" id="myModalLabel">选择模型</h4>
				<button type="button" class="close" data-dismiss="modal">x</button>
			</div>
			<div class="modal-body">
				<table class="table table-striped table-centered mb-0">
					<thead>
						<tr>
							<th>ID</th>
							<th>模型名称</th>
							<th>模型数据表</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="model_list" id="data"}
						<tr>
							<td>{$data.id}</td>
							<td>{$data.model_name}</td>
							<td>{$data.model_table}</td>
							<td>
								{eq name="data.status" value="0"}
								<a href="javascript:;" class="badge badge-primary">启用</a>
								{else /}
								<a href="javascript:;" class="badge badge-secondary">禁用</a>
								{/eq}
							</td>
							<td>
								<a href="{:url('modelfield/index')}?mid={$data.id}" class="badge badge-primary">选择</a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
{/block}
